function e() {
    return (e = (0, t.default)(o.default.mark(function e(n, t, r, c, i, a, u, l) {
        return o.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                if ("single" != t) {
                    e.next = 3;
                    break;
                }
                e.next = 4;
                break;

              case 3:
                return e.abrupt("return", new Promise(function(e, o) {
                    wx.cloud.database().collection(n).where(c).skip(i).limit(a).orderBy(u[0], u[1]).field(l).get().then(function(n) {
                        if ("collection.get:ok" != n.errMsg) throw "查询失败";
                        console.log("正常返回数据"), e(n.data);
                    }).catch(function(e) {
                        o(new Error());
                    });
                }));

              case 4:
              case "end":
                return e.stop();
            }
        }, e);
    }))).apply(this, arguments);
}

var n = require("88E1D181C63E4BDFEE87B98694997135.js"), o = n(require("6FE2C700C63E4BDF0984AF0745B97135.js")), t = n(require("AB130690C63E4BDFCD756E97361A7135.js")), r = function(e) {
    return (e = e.toString())[1] ? e : "0" + e;
};

module.exports = {
    formatTime: function(e) {
        var n = e.getFullYear(), o = e.getMonth() + 1, t = e.getDate(), c = e.getHours(), i = e.getMinutes(), a = e.getSeconds();
        return [ n, o, t ].map(r).join("-") + " " + [ c, i, a ].map(r).join(":");
    },
    formatDate: function(e) {
        return [ e.getFullYear(), e.getMonth() + 1, e.getDate() ].map(r).join("-");
    },
    formatTimeNew: function(e) {
        e.getFullYear(), e.getMonth(), e.getDate();
        var n = e.getHours(), o = e.getMinutes();
        return e.getSeconds(), [ n, o ].map(r).join(":");
    },
    wxPromisify: function(e) {
        return function() {
            var n = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
            return new Promise(function(o, t) {
                n.success = function(e) {
                    o(e);
                }, n.fail = function(e) {
                    t(e);
                }, e(n);
            });
        };
    },
    getData: function(e, n, o, t, r, c, i, a) {
        return "single" == n ? (console.log("获取单条记录"), new Promise(function(n, t) {
            wx.cloud.database().collection(e).doc(o).field(a).get().then(function(e) {
                "document.get:ok" == e.errMsg ? (console.log("获取单条记录……成功"), n(e.data)) : (console.log("查询数据库失败,错误信息:" + e.errMsg), 
                t("查询数据库失败,错误信息:" + e.errMsg));
            }).catch(function(e) {
                console.log("查询数据库失败"), t(JSON.parse(JSON.stringify(e)));
            });
        })) : (console.log("获取多条记录……"), new Promise(function(n, o) {
            wx.cloud.database().collection(e).where(t).skip(r).limit(c).orderBy(i[0], i[1]).field(a).get().then(function(e) {
                "collection.get:ok" == e.errMsg ? (console.log("获取多条记录……成功"), n(e.data)) : (console.log("查询数据库失败,错误信息:" + e.errMsg), 
                o("查询数据库失败,错误信息:" + e.errMsg));
            }).catch(function(e) {
                console.log("查询数据库失败"), o(JSON.parse(JSON.stringify(e)));
            });
        }));
    },
    getDataAsync: function(n, o, t, r, c, i, a, u) {
        return e.apply(this, arguments);
    },
    updateData: function(e, n, o, t, r) {
        return "single" == n ? (console.log("更新单条记录"), new Promise(function(n, t) {
            wx.cloud.database().collection(e).doc(o).update({
                data: r
            }).then(function(e) {
                console.log(e), "document.update:ok" == e.errMsg && 1 == e.stats.updated ? (console.log("更新成功"), 
                n("更新成功")) : (console.log("更新失败,错误信息:" + e.errMsg), t(e.errMsg));
            }).catch(function(e) {
                console.log("更新失败"), console.log(e), t(JSON.parse(JSON.stringify(e)));
            });
        })) : (console.log("更新多条记录……"), new Promise(function(n, o) {
            wx.cloud.database().collection(e).where(t).update().then(function(e) {
                console.log(e);
            }).catch(function(e) {
                console.log(e), console.log("更新失败"), o(JSON.parse(JSON.stringify(e)));
            });
        }));
    },
    getConfig: function() {
        return new Promise(function(e, n) {
            wx.cloud.database().collection("config").orderBy("date", "desc").limit(1).get().then(function(n) {
                e(n.data[0]);
            });
        });
    },
    getStarConfig: function(e) {
        return new Promise(function(n, o) {
            wx.cloud.database().collection("star").where({
                config: {
                    weibo: {
                        uid: e
                    }
                }
            }).get().then(function(e) {
                n(e.data[0].config);
            });
        });
    },
    compare: function(e) {
        return function(n, o) {
            var t = n[e];
            return o[e] - t;
        };
    }
};